<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <div>
        <button @click="jump('index')">首页</button>
        <button @click="jump('article')">文章</button>
    </div>
    <router-view></router-view>
</div>
</body>
<script src="../../js/vue.js"></script>
<script src="../../js/vue-router.js"></script>
<script type="text/javascript">
    const Index = Vue.component('index', {
        template: '<div>Hello，欢迎使用慕课网学习 Vue 教程！</div>',
    })

    const Article = Vue.component('myArticle', {
        template: `<ul><li>1. Vue 计算属性的学习</li><li>2. Vue 侦听器的学习</li></ul>`,
    })


    const routes = [
        { path: '/index', component: Index },
        { path: '/article', component: Article }
    ]

    const router = new VueRouter({
        routes: routes
    })

    var vm = new Vue({
        el: '#app',
        router,
        data() {
            return {}
        },
        methods: {
            jump(name) {
                this.$router.push(name)
            }
        }
    })
</script>
</html>
